import {
  _decorator,
  Component,
  Node,
  Graphics,
  NodeEventType,
  EventTouch,
  Event,
} from "cc";
const { ccclass, property } = _decorator;

@ccclass("Edit")
export class Edit extends Component {
  @property({ type: Graphics })
  gai: Graphics;
  start() {
    this.node.on(NodeEventType.TOUCH_START, this.ondowm, this);
  }
  ondowm(ent: EventTouch) {
    const size = 10; //点的大小
    const offset = size / 2; //计算偏移居中鼠标
    const pos = ent.getLocation(); //拿到当前鼠标点在gai节点上的位置
    const g = this.gai;
    g.fillColor.fromHEX(String("#").concat(Math.floor((Math.random() * 1e7)).toString(16)));
    g.rect(pos.x - offset, pos.y - offset, size, size);
    g.fill();
  }
}
